<!DOCTYPE html>
<html>
    <head>
        <meta charset='utf-8' />
        <title>居中显示</title>
        <style>
            #nav{
                width:400px;
                height:300px;
                position:fixed;
                left:50%;top:50%;
                background-color:deeppink;
                opacity:0.5;
                margin-left:-200px;   /*纠正宽*/
                margin-top:-150px;    /*纠正高*/
            }
        </style>
    </head>
    <body>
        <div id='nav'></div>      
    </body>
</html>